from fastapi import Body
from services.api_wrap import async_api_wrapper, BaseResponse
from classify.news_topic_classify import TextClassifier
from typing import List

topic = TextClassifier()

@async_api_wrapper
async def classify_api(
        texts: List[str] = Body(description='文本列表'),
        lang: str = Body(description='语言')
):
    class_names = topic.predict(texts)
    return BaseResponse(data=class_names)